<style>
.fui-content {
   background: url("/addons/jy_xiuvote/resource/bg.jpg") no-repeat #79557b;
   background-size: cover;
   height: 100%;
}
</style>
<div id="followbar" class="modal fade" tabindex="-1" style="display:none;">
		<div class="modal-dialog" style="width:60%;left:20%">
			<div class="modal-content">
				<div class="wap-qrcode-container">
					<p class="example1">{{pagedata.pluginset.title || '欢迎浏览'}}</p>
						<div class="wap-qrcode-image">
							<img ng-src="{{tomedia(pagedata.pluginset.ewm) || '../core/resource/images/nopic.jpg'}}"/>
						</div>
					<p class="example1">长按二维码关注</p>
				</div>
			</div>
		</div>
</div>
<div class="fui-page">
<div class="fui-content" style="color:#fff">
	<div class="fui-article-content" style="padding:0.5rem">
		<video style="width:100%;max-height:16rem" ng-src="{{tomedia(pagedata.opus.video)}}" poster="{{tomedia(pagedata.opus.thumb)}}" x5-playsinline="" playsinline="" webkit-playsinline="" preload="auto"  preload="auto" controls loop="loop">
		</video>
	</div>
	<div class="jy-content" style="padding-top:0.5rem">
	<div class="bold" style="font-size:1rem;color:#fff">{{pagedata.opus.realname || '选手名称'}}</div>
	<div style="font-size:0.65rem;padding-bottom:0.7rem">
	编号{{pagedata.opus.id || '001'}}<span class="r-f">当前排名：<span style="font-size:0.9rem">NO.{{pagedata.opus.rankkey||1}}</span></span>
	</div>
	<div style="font-size:0.65rem;height:2.6rem;border-top:1px solid rgb(231, 231, 235)">
	<span class="r-f">当前票数：<span style="font-size:0.9rem;color:#f557ae">{{pagedata.opus.votenums}}</span> 票</span>
	</div>
	<div class="c">
		<img style="width:8rem;display: inline;" ng-click="pagedata.setvote()" ng-src="{{tomedia(pagedata.basic.btnlike)||'/addons/jy_xiuvote/resource/btnlike.png'}}"/>
	</div>
	</div>
</div>
<div ng-include="sys_html('_itemfooter')"></div>
</div>
<script>
scope.pagedata.post = {}
scope.pagedata.post.money = 10
scope.pagedata.showhongbao=function(){
	$('body').addClass('fixed');
	$('#showhongbao').modal();
}
/*setTimeout(function(){
	wx.getNetworkType({
	  success: function (res) {
		document.getElementById('videoplay').play();
	  }
	});
},1000);*/
function clearNoNum(obj) {  
    obj.value = obj.value.replace(/[^\d.]/g,""); //清除"数字"和"."以外的字符  
        obj.value = obj.value.replace(/^\./g,""); //验证第一个字符是数字而不是  
        obj.value = obj.value.replace(/\.{2,}/g,"."); //只保留第一个. 清除多余的  
        obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");  
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3'); //只能输入两个小数  

}
scope.pagedata.getitem=function(type){
	if(type==1){
		var oid=scope.pagedata.onid
	}else{
		var oid=scope.pagedata.nextid
	}
	scope.page_loading();
	scope.get('jy_xiuvote/o_detail//id='+oid,function(res){
		scope.pagedata=$.extend(scope.pagedata,res)
		scope.page_loading('hide');
		if(scope.pagedata.item.video){
			live(1);
		}
		scope.$evalAsync();
	});
}
//概率计算
scope.pagedata.random=function(rate){
	var rate = parseInt(rate);
	var n = Math.random() * 100;
	if(n <= rate){
		return true
	}else{
		return false
	}
}
//发红包
scope.pagedata.sendhb=function(){
	scope.post_json('jy_xiuvote/o_detail/sendhb/',{'money':scope.pagedata.post.money,'username':scope.pagedata.post.username},function(res){
			if(res.payid){
				require(['tool'],function(tool){
					tool.pay(res.payid,function(res){
						if(res.type=='success'){
							$('#showhongbao').modal('hide');
							scope.message('支付成功！');
							
						}else{
							scope.message('支付失败！失败原因：'+res.message,'error');
						}
					});
				});
			}
	});

}
scope.pagedata.chouhb=function(){
	scope.post_json('jy_xiuvote/o_detail/chouhb/',{},function(res){
			if(res.ok){
				scope.pagedata.redmoney = res.fee;
				setTimeout($('#loadingToast').modal(),500);
			}else{
				scope.message(res.msg)
			}
	});
}
//获取点赞
scope.pagedata.setlike=function(){
	scope.post_json('jy_xiuvote/o_detail/like/',{'like':scope.pagedata.islike},function(res){
			if(res.success == 1){
				scope.message('点赞成功！');
				scope.pagedata.opus.likes++
				scope.$evalAsync();
				var time = 0
				for(var i = 0;i<88;i++){
					setTimeout('likepiaofu()',time);
					if(i<10){
						time += 100
					}else if(i>=10 && i<20){
						time += 200
					}else if(i>=20 && i<30){
						time += 300
					}else if(i>=30 && i<40){
						time += 400
					}else if(i>=40 && i<50){
						time += 500
					}else if(i>=50 && i<60){
						time += 600
					}else if(i>=60 && i<70){
						time += 700
					}else if(i>=70 && i<80){
						time += 800
					}else{
						time += 900
					}
				}
			}
	});
}
//收藏
scope.pagedata.setshoucang=function(){
	scope.post_json('jy_xiuvote/o_detail/shoucang/',{'isshoucang':scope.pagedata.isshoucang},function(res){
			scope.message(res)
	});
}
//获取关注
scope.pagedata.setfollow=function(){
	scope.post_json('jy_xiuvote/o_detail/follow/',{},function(res){
			scope.message(res)
			var time = 0
			for(var i = 0;i<88;i++){
				setTimeout('followpiaofu()',time);
				if(i<10){
					time += 100
				}else if(i>=10 && i<20){
					time += 200
				}else if(i>=20 && i<30){
					time += 300
				}else if(i>=30 && i<40){
					time += 400
				}else if(i>=40 && i<50){
					time += 500
				}else if(i>=50 && i<60){
					time += 600
				}else if(i>=60 && i<70){
					time += 700
				}else if(i>=70 && i<80){
					time += 800
				}else{
					time += 900
				}
			}
	});
}
//获取留言
scope.tool.get_list('jy_xiuvote/o_detail/getmsg/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_xiuvote/o_detail/getmsg/');
}
//提交留言
scope.pagedata.setmsg=function(msg,id){
	if(!msg){
		scope.message('发布失败，没有内容！','error');
	}
	scope.post_json('jy_xiuvote/o_detail/setmsg/',{'msg':msg,'id':id},function(res){
			scope.message(res.msg)
			vote_tanmu(msg,res.avatar)
	});
}
//提交礼物
scope.pagedata.sendlp=function(lpid){
	scope.post_json('jy_xiuvote/o_detail/sendlp/',{'lpid':lpid},function(res){
				if(res.payid){
					require(['tool'],function(tool){
						tool.pay(res.payid,function(res){
							if(res.type=='success'){
								$('#sendliping').modal('hide');
								scope.message('支付成功！');
								
							}else{
								scope.message('支付失败！失败原因：'+res.message,'error');
							}
						});
					});
				}
		
	});
}

//投票
scope.pagedata.setvote=function(type){
	scope.post_json('jy_xiuvote/o_detail/setvote/',{'code':scope.pagedata.post.code},function(res){
			scope.pagedata.post.code='';
			if(res){
				scope.pagedata.opus.votenums++
				scope.$evalAsync();
				scope.message('投票成功!');
			}else{
				scope.message(res);
			}
		
	});
}
//投票
scope.pagedata.getcode=function(){
	var logid=scope.pagedata.logid
	var rid=scope.pagedata.reply.id
	scope.post_json('jy_xiuvote/o_detail/getcode/logid='+logid+'&rid='+rid,{},function(res){
		scope.pagedata.vote_code=res.vote_code
		scope.$evalAsync();
		scope.message('领取成功!');
	});
}
function likepiaofu() {
		var x = 100;       
		var y = 330;
		var num = Math.floor(Math.random() * 6 + 1);
		var index=$('.likepiaofu').children('img').length;
		var rand = parseInt(Math.random() * (x - y + 1) + y); 
		$(".likepiaofu").append("<img src=''>");
		$(".likepiaofu").find('img:eq(' + index + ')').attr('src','../addons/jy_xiuvote/resource/img/like_icon_'+num+'.png')
		$(".likepiaofu").find("img").animate({
			bottom:"500px",
			opacity:"0",
			right: rand,
			width:"32px"
		},3000)
}
function followpiaofu() {
		var x = 100;       
		var y = 330;
		var num = Math.floor(Math.random() * 6 + 1);
		var index=$('.followpiaofu').children('img').length;
		var rand = parseInt(Math.random() * (x - y + 1) + y); 
		$(".followpiaofu").append("<img src=''>");
		$(".followpiaofu").find('img:eq(' + index + ')').attr('src','../addons/jy_xiuvote/resource/img/follow_icon_'+num+'.png')
		$(".followpiaofu").find("img").animate({
			bottom:"500px",
			opacity:"0",
			right: rand,
			width:"32px"
		},3000)
}
function reset_body(){
	document.body.scrollTop = document.body.scrollTop;
}
//信息弹窗：
//前端先注册以等待接收消息
require(['jinyun_socket'],function(jinyun_socket){
    jinyun_socket.connect();
    jinyun_socket.onsystem=function(res){
        if(res.message){
			var success_title = '确认';
			if(res.url){
				success_title = '前往查看';
			}
			scope.confirm({
						'message':res.message,
						'success':res.url,
						'success_title':success_title
			});
		}
    }
});
if(scope.pagedata.list.length>0){
	var msgs=scope.pagedata.list;
	var k=0
	for(var i = 0;i<msgs.length;i++){
		setTimeout(
			function(){
					vote_tanmu(msgs[k].content,msgs[k].avatar);
					k++;
			}
		,1700*i);
	}
}
function vote_tanmu(msg,picurl) {
		var x = 100;       
		var y = 330;
		var num = Math.floor(Math.random() * 6 + 1);
		var index=$('.video-sms-list').children('li').length;
		picurl=scope.tomedia(picurl);
		picurl = picurl?picurl:'../core/resource/images/nopic.jpg';
		$htmls = '<li class="video-sms-pane"><div class="video-sms-text"><img class="video-sms-logo" src="'+ picurl+'"/><span class="overflow-h">：'+msg+'</span></div></li>';
		$(".video-sms-list").append($htmls);
		$(".video-sms-list").find("li").animate({
			bottom:"600px",
			opacity:"0",
		},10000)
}
</script>